package com.shop.admin.service.user;

import com.shop.admin.dao.user.UserPinkBillDao;
import com.shop.domain.user.UserPinkBill;
import com.shop.web.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Slf4j
@Transactional
public class UserPinkBillService {

    @Autowired
    private UserPinkBillDao userPinkBillDao;

    /**
     * 增加用户佣金记录流水
     * @param userId  用户ID
     * @param linkId  关联ID（拼团订单ID）
     * @param pinkId  拼团ID
     * @param initialPrice  原始佣金
     * @param price  佣金
     * @param refreshPrice  更新后佣金
     * @param tableName 业务类型
     * @param pm 流水类型 0收入 1支出
     * @param mark 备注
     * @return
     */
    public BaseResponse addUserPinkBill(Long userId, Long linkId,Long pinkId, BigDecimal initialPrice, BigDecimal price,BigDecimal refreshPrice, String tableName,
                                     int pm, String mark) {

        UserPinkBill userPinkBill = new UserPinkBill();
        userPinkBill.setUid(userId);
        userPinkBill.setLinkId(linkId);
        userPinkBill.setPinkId(pinkId);
        userPinkBill.setInitialPrice(initialPrice);
        userPinkBill.setPrice(price);
        userPinkBill.setRefreshPrice(refreshPrice);
        userPinkBill.setTableName(tableName);
        userPinkBill.setPm(pm);
        userPinkBill.setMark(mark);
        userPinkBillDao.save(userPinkBill);

        return new BaseResponse();
    }


}
